<template>
    <div>
         <el-form  ref="addGoodsParamsForm" label-position='top'>
  <el-form-item
    :label='item.attr_name'
    v-for="item in onlyTable" :key="item.attr_id"
  >
    <el-input v-model="item.attr_vals"></el-input>
  </el-form-item>
   
   
</el-form>
    </div>
</template>

<script>
import {getCategoryParmasByAxios} from 'network/axios'
export default {
            name:'GoodsAttrForm',
              data(){
            return {
                addGoodsParamsForm:{
                  
                },
                cateId:0,
                //静态数据
                onlyTable:[],
              //传给后端的静态参数
                onlyAttr:[]
            }
        },
        created(){
            this.$bus.$on('sendCategoryId',(cateId)=>{
                        this.cateId=cateId
                        console.log(this.cateId);
                         getCategoryParmasByAxios({
                id:this.cateId,
                sel:'only'
            }).then(res=>{
                const {data}=res.data
                this.onlyTable=data
                console.log(this.onlyTable);
            })
            })

           
        },
        methods:{
          getAttrForm(){
            this.onlyTable.forEach(element=>{
                   const obj={attr_id:0,attr_value:''}
                    obj.attr_id=element.attr_id
                    obj.attr_value=element.attr_vals
                    this.onlyAttr.push(obj)
            })
  
          }
        }
}
</script>

<style>

</style>